#include "Reader.h"
#include "State.h"
#include "Empty.h"

Reader::Reader() : borrowed(0), state(new Empty())
{
}

Reader::~Reader()
{
    if (state != nullptr) {
        delete state;
    }
}

void Reader::ChangeState(State* s)
{
    if (state != nullptr) {
        delete state;
    }
    state = s;
}

void Reader::Borrow()
{
    state->Borrow(this);
}

void Reader::Return()
{
    state->Return(this);
}